package com.ucarbon.ucarbon.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ucarbon.ucarbon.service.ICountryLandstypeService;
import com.ucarbon.ucarbon.service.ICountryService;
import com.ucarbon.ucarbon.service.IYearsService;
import com.ucarbon.ucarbon.utils.RespBean;

/**
 * <p>
 * 土地利用类型与城年份对应信息 前端控制器
 * </p>
 *
 * @author XuGaoran
 * @since 2024-01-12
 */
@RestController
@RequestMapping("/ucarbon/countryLandstype")
public class CountryLandstypeController {

    @Autowired
    private IYearsService yearsService;

    @Autowired
    private ICountryService countryService;

    @Autowired
    private ICountryLandstypeService countryLandstypeService;

    @GetMapping("/queryLandtype")
    public RespBean queryLandty(@RequestParam String country, @RequestParam Integer year) {
        Boolean hasYear = yearsService.hasYear(year);
        Boolean hasCountry = countryService.hasCountry(country);
        if ((!hasYear.booleanValue()) || (!hasCountry.booleanValue())) {
            return RespBean.error("没有当前年份/城市数据!");
        }
        return countryLandstypeService.queryCountryYearLandty(country, year);
    }

}
